<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Db;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {

    }

    //将省市区用空格隔开
    public function audit_area_handle()
    {
        $lists = Db::name('teacher_audit')->select();
        foreach ($lists as $item) {
            if($item['holiday_pick']){
//                $str = $item['holiday_pick'];
//                $str = preg_replace('/省/', '省 ', $str);
//                $str = preg_replace('/市/', '市 ', $str);
//                Db::name('teacher_audit')->where([
//                    'id' => $item['id']
//                ])->update([
//                    'holiday_pick' => $str
//                ]);

                $str = $item['holiday_pick'];
                $arr = explode(" ", $str);
                Db::name('teacher_audit')->where([
                    'id' => $item['id']
                ])->update([
                    'holiday_areas' => $arr[2]
                ]);
            }
            if($item['unholiday_pick']){
//                $str = $item['unholiday_pick'];
//                $str = preg_replace('/省/', '省 ', $str);
//                $str = preg_replace('/市/', '市 ', $str);
//                Db::name('teacher_audit')->where([
//                    'id' => $item['id']
//                ])->update([
//                    'unholiday_pick' => $str
//                ]);

                $str = $item['unholiday_pick'];
                $arr = explode(" ", $str);
                Db::name('teacher_audit')->where([
                    'id' => $item['id']
                ])->update([
                    'unholiday_areas' => $arr[2]
                ]);
            }
        }
    }

    //寒暑假和非寒暑假授课区域弄反了
    public function holiday()
    {
        return;
        $teacher_list = Db::name('teacher')->select();
        foreach ($teacher_list as $item) {
            Db::name('teacher')->where([
                'user_id' => $item['user_id']
            ])->update([
                'holiday_area_lat' => $item['unholiday_area_lat'],
                'holiday_area_lng' => $item['unholiday_area_lng'],
                'unholiday_area_lat' => $item['holiday_area_lat'],
                'unholiday_area_lng' => $item['holiday_area_lng'],
            ]);
        }

        $audit_list = Db::name('teacher_audit')->select();
        foreach ($audit_list as $item) {
            Db::name('teacher_audit')->where([
                'id' => $item['id']
            ])->update([
                'holiday_area' => $item['unholiday_area'],
                'holiday_areas' => $item['unholiday_areas'],
                'holiday_pick' => $item['unholiday_pick'],
                'unholiday_area' => $item['holiday_area'],
                'unholiday_areas' => $item['holiday_areas'],
                'unholiday_pick' => $item['holiday_pick'],
            ]);
        }
    }

    //teacher_audit.give_lessons 字段 因为



}
